﻿Option Explicit On
Option Strict On

Imports System.Data
Imports System.Data.OleDb

Public Class FormAnyadirUsuario

    Dim Roles As Rol
    Dim Rol As Integer
    Dim DatosLeidos As OleDbDataReader

    Private Sub FormAnyadirUsuario_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Icon = My.Resources.icono_campeonato
        Roles = New Rol()

        DatosLeidos = Roles.ConsultarBD("Nombre")

        While DatosLeidos.Read
            cbx_Rol.Items.Add(CStr(DatosLeidos(0)))
        End While

    End Sub

    Private Sub btn_Aceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Aceptar.Click

        If cbx_Rol.Text = "Usuario" Then
            Rol = 2
        Else
            Rol = 1
        End If

        Dim UsuarioInsertar As New Usuario(tb_Usuario.Text, tb_Password.Text, Rol)
        UsuarioInsertar.InsertarEnBD(UsuarioInsertar)

    End Sub
End Class